package SGEngine

import (
	gl "github.com/gl"
)

type Scene struct {
	Node
	BgColor     Color3
	Cameras     []ICamera
	SceneWidth  float64
	SceneHeight float64
}

func CreateScene() *Scene {
	RScene := new(Scene)
	RScene.Node = DefaultNode()
	RScene.SetSize(float64(WinRoot.Width), float64(WinRoot.Height), 1)
	RScene.SceneWidth = float64(WinRoot.Width)
	RScene.SceneHeight = float64(WinRoot.Height)
	gl.Viewport(0, 0, WinRoot.Width, WinRoot.Height)

	return RScene
}

func ResetViewSize() {
	gl.Viewport(0, 0, WinRoot.Width, WinRoot.Height)
	WinRoot.MainScene.SetSize(float64(WinRoot.Width), float64(WinRoot.Height), 1)
}

func (s *Scene) AddCamera(cam ICamera) {
	cam.SetScene(s)
	s.Cameras = append(s.Cameras, cam)

}

func (s *Scene) SceneLoop() {
	for _, v := range s.Cameras {
		v.SetCamera()
		v.RenderNodes(s)
	}
}
